diff -Naur xspacewarp-1.2/actions.cc xspacewarp-1.2.patched/actions.cc
--- xspacewarp-1.2/actions.cc	2021-10-12 04:25:30.580232070 -0400
+++ xspacewarp-1.2.patched/actions.cc	2021-10-12 05:37:05.063841685 -0400
@@ -287,6 +287,7 @@
     break;
   case 'n':			// quit xspacewarp
     cout << "Live long and prosper!" << endl;
+    XCloseDisplay(XtDisplay(w));
     exit(0);
   default:
     cerr << "xspacewarp: replay: unknown argument in X defaults." << endl;
@@ -310,6 +311,12 @@
   }
 }
 
+void quit(Widget w, XEvent *event, String *str, Cardinal *len) {
+	if(event->type == ClientMessage && ((Atom) event->xclient.data.l[0]) == wm_delete_window) {
+		XCloseDisplay(XtDisplay(w));
+		exit(0);
+	}
+}
 
 // not an action but invoked by one.
 // Initialize Jovian AI data and start AppTimeOuts so jovians
diff -Naur xspacewarp-1.2/globals.hh xspacewarp-1.2.patched/globals.hh
--- xspacewarp-1.2/globals.hh	1995-12-29 02:41:39.000000000 -0500
+++ xspacewarp-1.2.patched/globals.hh	2021-10-12 05:03:56.900022417 -0400
@@ -24,6 +24,7 @@
 extern Pixmap pixmap;
 extern GC def_GC, defrv_GC, faserGC, faserGC_rv, torpGC, torpGC_rv, explodeGC;
 extern GC endeverGC, baseGC, jovianGC, starGC, blackholeGC;
+extern Atom wm_delete_window;
 
 extern Sector universe[UROWS][UCOLS];
 extern GameState gamestate;
diff -Naur xspacewarp-1.2/xprep.cc xspacewarp-1.2.patched/xprep.cc
--- xspacewarp-1.2/xprep.cc	2021-10-12 04:25:30.587232070 -0400
+++ xspacewarp-1.2.patched/xprep.cc	2021-10-12 05:23:53.950913600 -0400
@@ -28,6 +28,7 @@
 static int read_dashes(const char *, char *);
 static void check_values(void);
 
+Atom wm_delete_window;
 
 void xprep(int argc, char **argv)
 {
@@ -66,6 +67,10 @@
 
   XtRealizeWidget(toplevel);
 
+  wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
+  XSetWMProtocols(XtDisplay(toplevel), XtWindow(toplevel), &wm_delete_window, 1);
+  XtOverrideTranslations(toplevel, XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()"));
+
   // if desired, install an invisible mouse cursor
   // that does not block view of xspacewarp.
 
diff -Naur xspacewarp-1.2/xprep.hh xspacewarp-1.2.patched/xprep.hh
--- xspacewarp-1.2/xprep.hh	2021-10-12 04:25:30.588232069 -0400
+++ xspacewarp-1.2.patched/xprep.hh	2021-10-12 05:29:26.455883374 -0400
@@ -39,6 +39,7 @@
 extern void endinput(Widget, XEvent *, String *, Cardinal *);
 extern void replay(Widget, XEvent *, String *, Cardinal *);
 extern void pause(Widget, XEvent *, String *, Cardinal *);
+extern void quit(Widget, XEvent *, String *, Cardinal *);
 
 static XtActionsRec actions[] =
 {
@@ -58,7 +59,8 @@
   {(char*)"backspace", (XtActionProc)backspace},
   {(char*)"endinput", (XtActionProc)endinput},
   {(char*)"replay", (XtActionProc)replay},
-  {(char*)"pause", (XtActionProc)pause}
+  {(char*)"pause", (XtActionProc)pause},
+  {(char*)"quit", (XtActionProc)quit},
 };
 
 
